package me.notfirecodes.suicidehunt;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class RestockCMD implements CommandExecutor{
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            if(player.hasPermission("suicidehunt.restock")){
                player.sendMessage(ChatColor.GREEN + "Your items were manually restocked!");
                player.getInventory().clear();
                ItemStack itemst1 = new ItemStack(Material.SLIME_BLOCK, 64);
                ItemStack itemst2 = new ItemStack(Material.HAY_BLOCK, 64);
                ItemStack itemst3 = new ItemStack(Material.WATER_BUCKET, 1);
                ItemStack itemst4 = new ItemStack(Material.FISHING_ROD, 1);
                ItemStack itemst5 = new ItemStack(Material.ENDER_PEARL, 64);
                ItemStack itemst6 = new ItemStack(Material.COBWEB, 64);
                ItemStack itemst7 = new ItemStack(Material.SPLASH_POTION, 64);
                ItemStack itemst8 = new ItemStack(Material.SPONGE, 64);
                player.getInventory().addItem(itemst1);
                player.getInventory().addItem(itemst2);
                player.getInventory().addItem(itemst3);
                player.getInventory().addItem(itemst4);
                player.getInventory().addItem(itemst5);
                player.getInventory().addItem(itemst6);
                PotionMeta pm = (PotionMeta) itemst7.getItemMeta();
                PotionEffect pef = new PotionEffect(PotionEffectType.HEAL, 1, 1);
                pm.addCustomEffect(pef, true);
                itemst7.setItemMeta(pm);
                player.getInventory().addItem(itemst7);
                player.getInventory().addItem(itemst8);
            }
            else{
                player.sendMessage(ChatColor.RED + "You do not have permission to run this command.");
            }
        }
        else{
            System.out.println(ChatColor.RED + "You cannot run this command with console!");
        }
        return true;
    }
}
